﻿using System.Collections.Generic;

namespace TShooter.TfsWord.TeamFoundation
{
    public static class ConnectionFactory
    {
        #region Constructors and member variables

        private static readonly Dictionary<string, ITfsConnection> _ConnectionCache = new Dictionary<string, ITfsConnection>();

        #endregion

        public static ITfsConnection GetConnection(ConnectionInfo connectionInfo)
        {
            ITfsConnection cn = new TfsConnection(connectionInfo);

            if (_ConnectionCache.ContainsKey(cn.ToString()))
            {
                return _ConnectionCache[cn.ToString()];
            }

            _ConnectionCache.Add(cn.ToString(), cn);

            return cn;
        }
    }
}